
local ESN_Love = LibStub("AceAddon-3.0"):NewAddon("ESN_Love", "AceEvent-3.0")

local zeit = 2 --Hier die Zeit zwischen zwei Anzeigen einstellen

local LoveGuild = {
	["Pax Dei"] = true, --Diese Zeile einfach kopieren und Pax Dei durch andere Gilde ersetzen
}

local LoveName = {
	["Andiloewe"] = true, --Diese Zeile einfach kopieren und Andiloewe durch anderen Charakter ersetzen
}

function ESN_Love:OnInitialize()
	self:RegisterEvent("UPDATE_MOUSEOVER_UNIT","Love")
end

function ESN_Love:Output(mname,mguild,typ)
local output = true
	if (GetNumRaidMembers() > 0) then
		for i = 1, 40 do
			local name = GetRaidRosterInfo(i);
			if (name and (name ~= "")) then
				if name ~= mname then
					output = true
				else
					output = false
					break
				end
			end
		end
	elseif (GetNumPartyMembers() > 0) then
		for i = 1, 4 do
			local name = UnitName("party"..i);
			if (name and (name ~= "")) then
				if name ~= mname then
					output = true
				else
					output = false
					break
				end
			end
		end
	end
	if UnitName("player") ~= mname and output then
		PlaySoundFile([[Interface\AddOns\ESN_Love\Fun\alarm.mp3]])
		if typ == "Guild" then
			UIErrorsFrame:AddMessage("Nette Gilde: "..mname.." von "..mguild, 0, 1, 0, 77, 3);
			DEFAULT_CHAT_FRAME:AddMessage("Nette Gilde: "..mname.." von "..mguild, 0.0, 1.0, 0.0);
		elseif typ == "Name" then
			UIErrorsFrame:AddMessage("Nette Person: "..mname, 0, 1, 0, 77, 3);
			DEFAULT_CHAT_FRAME:AddMessage("Nette Person: "..mname, 0.0, 1.0, 0.0);
		elseif typ == "Friend" then
			UIErrorsFrame:AddMessage("Freund: "..mname, 0, 1, 0, 77, 3);
			DEFAULT_CHAT_FRAME:AddMessage("Freund: "..mname, 0.0, 1.0, 0.0);
		end
	end
end

function ESN_Love:Love()
local inInstance, instanceType = IsInInstance()
if instanceType == "party" or instanceType == "raid" then
-----nix
else
	if UnitExists("mouseover") then
		local mname = UnitName("mouseover")
		local mguild = GetGuildInfo("mouseover") or " "
----------------------Guildlist
		for LGuild in pairs(LoveGuild) do
			if LGuild == mguild and UnitExists("mouseover") then
				if self.ti == nil or (GetTime() - self.ti > zeit) then
					self.ti = GetTime()
					ESN_Love:Output(mname,mguild,"Guild")
				end	
			end
		end		
----------------------Namelist
		for LName in pairs(LoveName) do
			if LName == mname and UnitExists("mouseover") then
				if self.ti == nil or (GetTime() - self.ti > zeit) then
					self.ti = GetTime()
					ESN_Love:Output(mname,mguild,"Name")
				end	
			end
		end	
----------------------Friendlist
		for i = 1,GetNumFriends() do
			local name = GetFriendInfo(i)
			if name == mname and UnitExists("mouseover") then
				if self.ti == nil or (GetTime() - self.ti > zeit) then
					self.ti = GetTime()
					ESN_Love:Output(mname,mguild,"Friend")
				end
			end
		end	
	end
end
end
